#ifndef PLAYERCONTROLLER_H
#define PLAYERCONTROLLER_H

#include <QAxWidget>
#include "commonmessage.h"

enum PlayerState{
    STOP = 1,
    PAUSE = 2,
    PLAYING = 3,
    END = 8,
    READY = 9,
    IDLE = 10
};

struct MediaInfo{
    QString title;
    QString duration;
};

class PlayerController : public QObject
{
    Q_OBJECT
public:
    explicit PlayerController(QObject *parent = nullptr, QAxWidget* ax = nullptr);
    ~PlayerController();

    void openFile(QString path);
    void setFullScreen();

    PlayerState getPlayState();
    QString getProcessBarInfo();
    MediaInfo getCurrentMediaInfo();
    bool setPlayState(PlayerState state);
    void setCurrentPosition(QString pos);

    static QString stateToString(QString state);
    static QString stateToString(PlayerState state);
    static QString timeToString(double time);
    static QString timeToString(QString time);
private slots:
    void onPlayStateChange(int);
    void onPositionChange(double, double);
private:
    void start();
    void pause();
    void stop();
    PlayerState playState;
    const QString CLSID = "{6BF52A52-394A-11d3-B153-00C04F79FAA6}";
    QAxWidget* axWidget;
    QAxObject *controls;
    QAxObject *currentMedia;
signals:
    void sendMsgToMain(MesSource, CommonMessage);
};




#endif // PLAYERCONTROLLER_H
